/**
 * Created by Julia on 2016/4/28.
 */

define(['jquery', 'stringUtils'], function ($, stringUtils) {
    return {
        colors: {
            danger: "#A65858",
            primary: "#5384AF",
            warning: "#C79121",
            success: "#739E73",
            backgroundBox: "#296191",
            red: 'brown',
            blue: '#3276B1',
            green: '#71843F',
            degreen: '#568A89'
        },
        searchKey: {
            search_user_key: "ispc.search.condition.user.",
            search_role_key: "ispc.search.condition.role.",
            search_group_key: "ispc.search.condition.group.",
            search_dataImport_timeout_key: "ispc.dataImport.timeout.spc.",
            search_dataImport_project_key: "ispc.dataImport.project.",
            search_dataImport_solt_key:"ispc.dataImport.spc.solt"
        },
        ajax: {
            timeout: 20000
        },
        fieldMaxSize: 40,
        getFormatFieldText: function (opt) {
            if (opt == null) {
                return "";
            }
            if (stringUtils.isBlank(opt.text)) {
                return "";
            }
            var len = this.fieldMaxSize;
            if (stringUtils.isNotBlank(opt.maxSize)) {
                len = opt.maxSize;
            }
            var result = opt.text;
            if (result.length > len) {
                var content = opt.text.substring(0, len) + "...";
                result = "<span rel='tooltip' style='width:100%' title='" + opt.text+ "' data-placement='bottom' data-original-title='" + opt.text + "'>" + content + "</span>";
            }
            return result;
        },
        table_language: function () {
            return {
                "emptyTable": $.i18n.prop('GLOBAL_TABLE_LANG_EMPTY'),
                "info": $.i18n.prop('GLOBAL_TABLE_LANG_INFO', '_START_', '_END_', '_TOTAL_'),
                "infoEmpty": $.i18n.prop('GLOBAL_TABLE_LANG_INFO_EMPTY'),
                "zeroRecords": $.i18n.prop('GLOBAL_TABLE_LANG_ZERORECORDS'),
                "lengthMenu": $.i18n.prop('GLOBAL_TABLE_LANG_LENGTHMENU', '_MENU_'),
                "processing": "",
                "paginate": {
                    "first": $.i18n.prop('GLOBAL_TABLE_LANG_PAGINATE_FIRST'),
                    "last": $.i18n.prop('GLOBAL_TABLE_LANG_PAGINATE_LAST'),
                    "next": $.i18n.prop('GLOBAL_TABLE_LANG_PAGINATE_NEXT'),
                    "previous": $.i18n.prop('GLOBAL_TABLE_LANG_PAGINATE_PREVIOUS')
                }
            };
        },
        drawNumber_bg: function (table) {
            table.DataTable().on('draw.dt', function () {
                var dt = $(this).dataTable();
                dt.api().column(0, {draw: 'applied'}).nodes().each(function (cell, i) {
                    var pageNum = dt.api().page();
                    var pageSize = dt.api().page.len();
                    cell.innerHTML = pageNum * pageSize + i + 1;
                });
            });
        },
        drawNumber_ui: function (table) {
            table.DataTable().on('draw.dt', function () {
                var dt = $(this).dataTable();
                dt.api().column(0, {draw: 'applied'}).nodes().each(function (cell, i) {
                    cell.innerHTML = i + 1;
                });
            });
        },
        clearTable: function (table) {
            table.DataTable().ajax.url("empty").load();
        }
    }
});